package ctm.javacode;

import java.io.*;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.lang.*;
import java.net.URLEncoder;
import com.mysql.jdbc.StringUtils;

@WebServlet("/readcaseHistory.do")
public class readcaseHistory extends HttpServlet {

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		/****** 設定 ******/
		response.setContentType("text/html");
		response.setCharacterEncoding("UTF-8");
		
		/****** 資料庫變數 ******/
		String sqlQuery = "";
		ResultSet rs;
		dbBean db = new dbBean();
		db.setDataSource("jdbc/ctmpllab");
		db.Connected();
		PrintWriter out = response.getWriter();// Write the response back to the browser
		
		String username = (String)request.getSession().getAttribute("login");
		String personId = request.getParameter("personId"); //身分證字號字號		
		String diseas = "正常人狀態";	
		
		/****** 資料庫抓取資料 ******/
		sqlQuery = "SELECT * FROM `casehistorytable` WHERE account =" + "'" + personId + "'";
		try {
			rs = db.ExcuteQuery(sqlQuery);
			rs.next();
			if (rs.getRow() != 0) {
				diseas = rs.getString("history");
			}
			db.CloseConn();
			out.print(diseas);
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
}
